#pragma once

#include <string>
#include <vector>
#include <numeric>
#include <cmath>

namespace Bud
{
    using ll = long long;
    std::vector<ll> getDivs( ll value ) {
        std::vector<ll> res{};

        for ( ll i = 2; i <= sqrt( value ); ++i )
        {
            if ( value % i == 0 )
            {
                res.push_back( i );
                res.push_back( value / i );
            }
        }

        return res;
    }

    ll sumDivs( ll value ) {
        auto divs = getDivs( value );
        return std::accumulate( divs.cbegin(), divs.cend(), 0 );
    }

    std::string buddy( ll start, ll limit ) {
        for ( auto first = start; first <= limit; ++first )
        {
            auto second = sumDivs( first );
            auto chec = sumDivs( second );

            if ( second > first && sumDivs( second ) == first )
            {
                return "(" + std::to_string( first ) + " " + std::to_string( second ) + ")";
            }
        }

        return "Nothing";
    }
}
